<?php

namespace Biz\SharingLog;

use Base\Exception\NoRecordException;

class SharingLog extends \Base\BaseBiz
{
    /**
     * @param $id
     * @return \Orm\SharingLog\SharingLogClass
     * 获取信息
     */
    public static function getInfo($id)
    {
        $player_orm = new \Orm\SharingLog\SharingLogClass();
        $player_orm->loadById($id);
        return $player_orm;
    }

    /**
     * @param $where
     * @param int $now
     * @param int $size
     * @return array
     * 获取列表
     */
    public static function getList($where, $now = 1, $size = 0)
    {
        $now = ($now > 0)?$now:1;
        $size = ($size > 0)?$size:\Util\Config::get('max_limit');

        $player_list = new \Orm\SharingLog\SharingLogList();
        if (!empty($where)) {
            $player_list['where'] = $where;
        } else {
            $player_list['where'] = '';
        }
        $player_list['limit'] = $size;
        $player_list['offset'] = ($now - 1) * $size;
        $player_list['order'] = '`insert_time` desc';
        $player_list['key_by'] = 'id';
        $player_list->load();

        $result = array();
        $result['lists'] = $player_list['lists'];
        $result['total'] = $player_list['total'];
        return $result;
    }

    /**
     * @param $user_id
     * @param $time
     * @return array
     */
    public static function getShareByUidAndTime($user_id,$time){
        $share_model = new \Orm\SharingLog\SharingLogModel();
        return $share_model->getShareByUidAndTime($user_id,$time);
    }
}
